#include "StdAfx.h"
#include "Chartdata.h"
#include <math.h>


CChartdata::CChartdata(void)
{
	nYMin = 100;
	nYMax = 0;
}


CChartdata::~CChartdata(void)
{
	Clear(1);
}

int CChartdata::Add(float fOrgin, float fDest, int hour, int min, int sec, int year, int month,	int day)
{
	int nSize = 0;
	__ITEM* item = new __ITEM;
	item->fOrigin = fOrgin;
	item->fDest = fDest;
	//item->fIntv = fabs(fOrgin-fDest);
	item->fIntv = fOrgin+fDest;
	item->Hour = hour;
	item->Min = min;
	item->Sec = sec;
	item->Year = year;
	item->Month = month;
	item->Day = day;	
	lstData.Add(item);

	nSize = lstData.GetSize();
	if(nSize > m_config.nInitWidth)
		m_config.bGraphMoving = TRUE;
	else
		m_config.bGraphMoving = FALSE;

	if(nSize == 1)
		nYMin = nYMax = item->fIntv;
	else if(item->fIntv < nYMin)
		nYMin = item->fIntv;
	else if(item->fIntv > nYMax)
		nYMax = item->fIntv;

	return nSize;
}

void CChartdata::Clear(int origin)
{
	if(origin == 1){
		for(int i=lstData.GetSize()-1; i>=0; i--){
			delete lstData.GetAt(i);
		}
		lstData.RemoveAll();
	}
	m_config.bGraphMoving = FALSE;
/*
	else
	{
		for(int i=copyData.GetSize()-1; i>=0; i--){
			delete copyData.GetAt(i);
		}
		copyData.RemoveAll();
	}*/	
}

void CChartdata::dataCopy()
{
	//lstData.Copy(copyData);
}